import { request } from '@/utils/request'
import type { IntervalStrDTO, PageDTO, PageRes, SortDTO } from '@/types/global'
import type { AddRoleDTO, QueryRoleDTO, RoleDTO, UpdateRoleDTO } from '@/types/role'

export function queryRoleList(params: PageDTO & SortDTO & IntervalStrDTO & QueryRoleDTO) {
  return request.get<PageRes<RoleDTO>>('/api/role', { params })
}

export function addRole(data: AddRoleDTO) {
  return request.post('/api/role', data)
}

export function getRoleById(id: number) {
  return request.get<RoleDTO>('/api/role/' + id)
}

export function updateRole(data: UpdateRoleDTO) {
  return request.put('/api/role', data)
}

export function queryAllRole() {
  return request.get<RoleDTO[]>('/api/role/queryAllRole')
}

export function deleteRoleByIds(idList: any) {
  return request.delete('/api/role', {
    params: {
      idList: idList
    }
  })
}
